﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="IEntityRepository.cs" company="Collaboris Ltd.">
//   Copyright (c) Collaboris Ltd. All rights Reserved.
// </copyright>
// <summary>
//   The i entity repository.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace Collaboris.DataAccess.Linq
{
    #region Imports

    using System;
    using System.Collections.Generic;
    using System.Data.Objects;
    using System.Linq;
    using System.Linq.Expressions;

    #endregion

    /// <summary>
    /// The i entity repository.
    /// </summary>
    /// <typeparam name="T">
    /// </typeparam>
    internal interface IEntityRepository<T> : IDisposable
    {
        /*
        /// <summary>
        /// Create a query for type T.
        /// </summary>
        ObjectQuery<T> CreateQuery(bool trackChanges);

        /// <summary>
        /// Create a query for type C.
        /// </summary>
        ObjectQuery<C> CreateQuery<C>(bool trackChanges);
*/

        /// <summary>
        /// Gets TrackChanges.
        /// Determines if the returned objects will have tracking enabled.
        /// </summary>
        bool TrackChanges
        {
            get;
            set;
        }

        /// <summary>
        /// Returns a new empty data entity
        /// </summary>
        /// <returns>
        /// </returns>
        T CreateDataEntity();

        /// <summary>
        /// The load.
        /// </summary>
        /// <param name="Id">
        /// </param>
        /// <returns>
        /// </returns>
        T Load(long Id);

        /// <summary>
        /// The load.
        /// </summary>
        /// <param name="filter">
        /// The filter.
        /// </param>
        /// <returns>
        /// </returns>
        T Load(Expression<Func<T, bool>> filter);

        /// <summary>
        /// Returns all the data entities in the repository
        /// </summary>
        /// <returns>
        /// </returns>
        List<T> LoadList();

        /// <summary>
        /// Returns a collection of data entities conforming with the filter expression
        /// </summary>
        /// <param name="query">
        /// </param>
        /// <returns>
        /// </returns>
        List<T> LoadList(ObjectQuery<T> query);

        /// <summary>
        /// Returns a collection of data entities conforming with the filter expression
        /// </summary>
        /// <param name="query">
        /// </param>
        /// <returns>
        /// </returns>
        List<T> LoadList(IQueryable<T> query);

        /// <summary>
        /// The submit.
        /// </summary>
        /// <param name="businessObject">
        /// </param>
        /// <returns>
        /// The submit.
        /// </returns>
        long Submit(T businessObject);

        /// <summary>
        /// Deletes the business object with the specified Id
        /// </summary>
        /// <param name="itemId">
        /// </param>
        void Delete(long itemId);

        /// <summary>
        /// Deletes the specified business object
        /// </summary>
        /// <param name="dataEntity">
        /// </param>
        void Delete(T dataEntity);
    }
}